How to use DataLoader

This is an example on how to use a DataLoader object


In [1]:
from __future__ import division
from terminaltables import AsciiTable

In [2]:
import inet
inet.__version__


Out[2]:
'0.0.14'

In [3]:
from inet import DataLoader

Object creation

The object loads the connectivity matrices in .syn format and reports the number of files loaded at construction.


In [4]:
mydataset = DataLoader('../../data/PV') # create an object with information of all connections


 190 syn  files loaded

Object atttributes

The object contains a list with all experiments loaded


In [5]:
len(mydataset.experiment)


Out[5]:
190

In [6]:
mydataset.nIN, mydataset.nPC # number of PV cells and GC cells recorded


Out[6]:
(237, 929)

In [7]:
mydataset.configuration # number of recording configurations


Out[7]:
{'octuples': 33,
 'pairs': 4,
 'quadruplets': 12,
 'quintuplets': 30,
 'septuplets': 54,
 'sextuplets': 49,
 'triplets': 8}

In [8]:
print(mydataset.motif) # number of connections tested and found for every type


+---------+-------+--------+
| Motif   | found | tested |
+---------+-------+--------+
| e2i     | 33    | 2307   |
| e3i     | 7     | 2826   |
| ee_c1e  | 0     | 4118   |
| ee_c2   | 0     | 2059   |
| ee_c2e  | 0     | 2059   |
| ee_chem | 0     | 4118   |
| ee_con  | 0     | 7776   |
| ee_div  | 0     | 7776   |
| ee_elec | 0     | 2059   |
| ee_lin  | 0     | 15552  |
| ei      | 91    | 1079   |
| ie      | 265   | 1079   |
| ii_c1e  | 18    | 110    |
| ii_c2   | 9     | 55     |
| ii_c2e  | 6     | 55     |
| ii_chem | 31    | 110    |
| ii_con  | 1     | 24     |
| ii_div  | 2     | 24     |
| ii_elec | 24    | 55     |
| ii_lin  | 2     | 48     |
+---------+-------+--------+

Details of every experiments are given in a list


In [9]:
mydataset.experiment[0] # example of the data from the first experiment


Out[9]:
{'fname': '2_170411_02.syn', 'matrix': array([[0, 2],
        [0, 0]]), 'motif': {'e2i': {'found': 0, 'tested': 0},
  'e3i': {'found': 0, 'tested': 0},
  'ee_c1e': {'found': 0, 'tested': 0},
  'ee_c2': {'found': 0, 'tested': 0},
  'ee_c2e': {'found': 0, 'tested': 0},
  'ee_chem': {'found': 0, 'tested': 0},
  'ee_con': {'found': 0, 'tested': 0},
  'ee_div': {'found': 0, 'tested': 0},
  'ee_elec': {'found': 0, 'tested': 0},
  'ee_lin': {'found': 0, 'tested': 0},
  'ei': {'found': 0, 'tested': 0},
  'ie': {'found': 0, 'tested': 0},
  'ii_c1e': {'found': 0, 'tested': 2},
  'ii_c2': {'found': 0, 'tested': 1},
  'ii_c2e': {'found': 0, 'tested': 1},
  'ii_chem': {'found': 0, 'tested': 2},
  'ii_con': {'found': 0, 'tested': 0},
  'ii_div': {'found': 0, 'tested': 0},
  'ii_elec': {'found': 1, 'tested': 1},
  'ii_lin': {'found': 0, 'tested': 0}}}

and details fo the recording configurations are provided


In [10]:
mydataset.experiment[12]['fname'] # mydataset.filename(12)


Out[10]:
'1_170313_01.syn'

In [11]:
mydataset.filename(12)


Out[11]:
'1_170313_01.syn'

In [12]:
mydataset.experiment[12]['matrix']


Out[12]:
array([[0, 1, 1, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0]])

In [13]:
mydataset.matrix(12)


Out[13]:
array([[0, 1, 1, 0, 0, 0, 0, 0],
       [1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0]])

In [14]:
print(mydataset.experiment[12]['motif'])


+---------+-------+--------+
| Motif   | found | tested |
+---------+-------+--------+
| e2i     | 0     | 21     |
| e3i     | 0     | 35     |
| ee_c1e  | 0     | 42     |
| ee_c2   | 0     | 21     |
| ee_c2e  | 0     | 21     |
| ee_chem | 0     | 42     |
| ee_con  | 0     | 105    |
| ee_div  | 0     | 105    |
| ee_elec | 0     | 21     |
| ee_lin  | 0     | 210    |
| ei      | 1     | 7      |
| ie      | 2     | 7      |
| ii_c1e  | 0     | 0      |
| ii_c2   | 0     | 0      |
| ii_c2e  | 0     | 0      |
| ii_chem | 0     | 0      |
| ii_con  | 0     | 0      |
| ii_div  | 0     | 0      |
| ii_elec | 0     | 0      |
| ii_lin  | 0     | 0      |
+---------+-------+--------+


In [15]:
mydataset.motifs(12)


Out[15]:
{'e2i': {'found': 0, 'tested': 21},
 'e3i': {'found': 0, 'tested': 35},
 'ee_c1e': {'found': 0, 'tested': 42},
 'ee_c2': {'found': 0, 'tested': 21},
 'ee_c2e': {'found': 0, 'tested': 21},
 'ee_chem': {'found': 0, 'tested': 42},
 'ee_con': {'found': 0, 'tested': 105},
 'ee_div': {'found': 0, 'tested': 105},
 'ee_elec': {'found': 0, 'tested': 21},
 'ee_lin': {'found': 0, 'tested': 210},
 'ei': {'found': 1, 'tested': 7},
 'ie': {'found': 2, 'tested': 7},
 'ii_c1e': {'found': 0, 'tested': 0},
 'ii_c2': {'found': 0, 'tested': 0},
 'ii_c2e': {'found': 0, 'tested': 0},
 'ii_chem': {'found': 0, 'tested': 0},
 'ii_con': {'found': 0, 'tested': 0},
 'ii_div': {'found': 0, 'tested': 0},
 'ii_elec': {'found': 0, 'tested': 0},
 'ii_lin': {'found': 0, 'tested': 0}}

or the type the number of configurations when two PV-positive cells were recorded


In [16]:
mydataset.IN[2]


Out[16]:
{'octuples': 5,
 'pairs': 4,
 'quadruplets': 3,
 'quintuplets': 2,
 'septuplets': 9,
 'sextuplets': 7,
 'triplets': 1}

Descriptive statistics

The stats attribute will return basis statistics of the whole dataset


In [17]:
y = mydataset.stats()

print AsciiTable(y).table


+-----------------+----------+
| Concept         | Quantity |
+-----------------+----------+
| Principal cells | 929      |
| Interneurons    | 237      |
|                 |          |
| Pairs           | 4        |
| Triplets        | 8        |
| Quadruplets     | 12       |
| Quintuplets     | 30       |
| Sextuplets      | 49       |
| Septuplets      | 54       |
| Octuplets       | 33       |
+-----------------+----------+

In [18]:
mymotifs = mydataset.motif
info = [
        ['Connection type', 'Value'],
        ['PV-PV chemical synapses', mymotifs.ii_chem_found],
        ['PV-PV electrical synapses', mymotifs.ii_elec_found],
        [' ',' '],
        ['PV-PV bidirectional chemical', mymotifs.ii_c2_found],
        ['PV-PV divergent chemical', mymotifs.ii_div_found],
        ['PV-PV convergent chemical', mymotifs.ii_con_found],
        ['PV-PV linear chemical', mymotifs.ii_lin_found],
        [''],
        ['PV-PV one chemical with electrical', mymotifs.ii_c1e_found],
        ['PV-PV bidirectional chemical with electrical', mymotifs.ii_c2e_found],
        [' ',' '],
        ['P(PV-PV) chemical synapse', mymotifs.ii_chem_found/mymotifs.ii_chem_tested],
        ['P(PV-PV) electrical synapse', mymotifs.ii_elec_found/mymotifs.ii_elec_tested],
        [''],
        ['P(PV-PV) bidirectional chemical synapse', mymotifs.ii_c2_found/mymotifs.ii_c2_tested],
        ['P(div) divergent chemical motifs', mymotifs.ii_div_found/mymotifs.ii_div_tested],
        ['P(div) convergent chemical motifs', mymotifs.ii_con_found/mymotifs.ii_con_tested],  
        ['P(chain) linear chain motifs', mymotifs.ii_lin_found/mymotifs.ii_lin_tested],
        [' ',' '],
        ['P(PV-PV) one chemical with electrical', mymotifs.ii_c1e_found/mymotifs.ii_c1e_tested],
        ['P(PV-PV) bidirectional chemical with electrical', mymotifs.ii_c2e_found/mymotifs.ii_c2e_tested],
        [' ',' '],
        ['PV-GC chemical synapses', mymotifs.ie_found],
        ['GC-PC chemical synapses', mymotifs.ei_found],
        [' ',' '],
        ['P(PV-GC) chemical synapse',mymotifs.ie_found/mymotifs.ie_tested],
        ['P(GC-PC) chemical synapse', mymotifs.ei_found/mymotifs.ei_tested],
        [' ',' '],
        ]


table = AsciiTable(info)
print (table.table)


+-------------------------------------------------+-----------------+
| Connection type                                 | Value           |
+-------------------------------------------------+-----------------+
| PV-PV chemical synapses                         | 31              |
| PV-PV electrical synapses                       | 24              |
|                                                 |                 |
| PV-PV bidirectional chemical                    | 9               |
| PV-PV divergent chemical                        | 2               |
| PV-PV convergent chemical                       | 1               |
| PV-PV linear chemical                           | 2               |
|                                                 |                 |
| PV-PV one chemical with electrical              | 18              |
| PV-PV bidirectional chemical with electrical    | 6               |
|                                                 |                 |
| P(PV-PV) chemical synapse                       | 0.281818181818  |
| P(PV-PV) electrical synapse                     | 0.436363636364  |
|                                                 |                 |
| P(PV-PV) bidirectional chemical synapse         | 0.163636363636  |
| P(div) divergent chemical motifs                | 0.0833333333333 |
| P(div) convergent chemical motifs               | 0.0416666666667 |
| P(chain) linear chain motifs                    | 0.0833333333333 |
|                                                 |                 |
| P(PV-PV) one chemical with electrical           | 0.163636363636  |
| P(PV-PV) bidirectional chemical with electrical | 0.109090909091  |
|                                                 |                 |
| PV-GC chemical synapses                         | 265             |
| GC-PC chemical synapses                         | 91              |
|                                                 |                 |
| P(PV-GC) chemical synapse                       | 0.245597775718  |
| P(GC-PC) chemical synapse                       | 0.0843373493976 |
|                                                 |                 |
+-------------------------------------------------+-----------------+